var path = require('path')


var assetsMap;
try{
    assetsMap = rootRequire('public/dist/assets-map.json');
}catch (e){
    assetsMap=false;
}
//console.log(assetsMap)
module.exports = function(options,context){
    if(typeof options !== 'string'){
        return 'param after getStatic should be string'
    }
    if($$is_dev){
        return $$config.devStaticBaseUrl+options
    }

    if(!assetsMap){
        throw new Error("fail to parse assetsMap.")
    }

    var endIndex = options.lastIndexOf('.')
    var key = options.substring(0,endIndex),
        ext = options.substring(endIndex+1)
    var path = assetsMap[key][ext]

    return path
}